<template>
	<view style="padding-top: 20upx;">
		<view class="webkit">
			<view style="line-height: 96upx;height: 96upx;margin-right: 30upx;width: 120upx;">对方昵称</view>
			<input class="flex" style="position: relative;line-height: 96upx;height: 96upx;" type="text" :value="showmobile" disabled/>
		</view>
		<view class="webkit">
			<view style="line-height: 96upx;height: 96upx;margin-right: 30upx;width: 120upx;">币种选择</view>
			<button type="default" @tap="actionSheetTap" style="background: transparent;border: 0;width: 100%;text-align: left;font-size: 14px;line-height: 48px;">{{coinName}}</button>
		</view>
		<view class="webkit">
			<view style="line-height: 96upx;height: 96upx;margin-right: 30upx;width: 120upx;">转账数量</view>
			<input class="flex" style="position: relative;line-height: 96upx;height: 96upx;" type="number" value="" placeholder="请输入您要转账的数量" @input='numInput' @blur='numInput' />
		</view>
		<view class="webkit">
			<view style="line-height: 96upx;height: 96upx;margin-right: 30upx;width: 120upx;">支付密码</view>
			<input class="flex" style="position: relative;line-height: 96upx;height: 96upx;" type="number" value="" placeholder="请输入支付密码" @input='pwdInput' password @blur='pwdInput' />
		</view>
		<view class="box" style="padding: 24upx;">
			<button type="warn" @click="submit">提交</button>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				coins:[],
				openid:"",
				showmobile:"",
				mobile:"",
				num:'',
				pwd:'',
				type:'0',
				coinName:"余额"
			};
		},
		onLoad:function(e){
			this.mobile = e.mobile
			var str= e.mobile;
			var str2 = str.substr(0,3)+"****"+str.substr(7);
			this.showmobile = str2
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			});
		},
		methods:{
			setAjax(){
				uni.request({
					url: 'https://bhh.ax1319.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.hyhz.zzks&app=1',
					method: 'POST',
					data: {'openid':this.openid,'mobile':this.mobile},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						console.log(res)
						uni.hideLoading()
						this.coins = res.data.coins
					},
					fail: () => {},
					complete: () => {}
				});
			},
			numInput(e){
				this.num = e.target.value
			},
			pwdInput(e){
				this.pwd = e.target.value
			},
			actionSheetTap(){
				var list = ['余额']
				for(var i in this.coins){
					list.push(this.coins[i].coinname)
				}
				this.list = list
				uni.showActionSheet({
					itemList: list,
					success: (e) => {
						this.coinName = this.list[e.tapIndex]
						if(e.tapIndex == 0){
							this.type = 0
						}else{
							for(var i in this.coins){
								if(this.coins[i].coinname == this.list[e.tapIndex]){
									this.type = this.coins[i].id
								}
							}
						}
					}
				})
			},
			submit(){
				if(this.num == ""){
					uni.showToast({
						title: '请填写数量',
						icon:"none"
					});
				}else if(this.pwd == ""){
					uni.showToast({
						title: '请填写支付密码',
						icon:"none"
					});
				}else{
					uni.request({
						url: 'https://bhh.ax1319.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.hyhz.dozzks&app=1',
						method: 'POST',
						data:{
							'openid':this.openid,
							'mobile':this.mobile,
							'num':this.num,
							'paypwd':this.pwd,
							'type':this.type
						},
						header:{'Content-Type':'application/x-www-form-urlencoded'},
						success: res => {
							uni.showToast({
								title: res.data.res,
								icon:"none"
							});
							if(res.data.code == 1){
								setTimeout(()=>{
									uni.reLaunch({
										url:'../../member'
									})
								},1500)
							}
						},
						fail: () => {},
						complete: () => {}
					});
				}
			}
		}
	}
</script>

<style>
.webkit{
	position: relative;
	background: #fff;padding: 0 24upx;
}
.webkit:before{
    content: " ";
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: -1px;
    height: 1px;
    border-top: 1px solid #ebebeb;
    color: #D9D9D9;
    -webkit-transform-origin: 0 0;
    -ms-transform-origin: 0 0;
    transform-origin: 0 0;
    -webkit-transform: scaleY(0.5);
    -ms-transform: scaleY(0.5);
    transform: scaleY(0.5);	
}
.webkit:last-child:before{
	display: none;
}
button:after{
	display: none;
}
</style>
